Skip to content

feat(dictation): recover Esc-cancelled recordings - #989

Draft
MarkShawn2020 wants to merge 3 commits into
Open-Less:betafrom
MarkShawn2020:codex/recover-esc-recordings
Draft

feat(dictation): recover Esc-cancelled recordings#989
MarkShawn2020 wants to merge 3 commits into
Open-Less:betafrom
MarkShawn2020:codex/recover-esc-recordings

Conversation

@MarkShawn2020

@MarkShawn2020 MarkShawn2020 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • make Esc recording recovery an explicit macOS/Windows recording setting that is off by default
  • keep the original direct-cancel behavior when the setting is off: no recovery history entry and no Continue capsule
  • when enabled, preserve WAV audio and a pending history entry, then let the user continue the same recording or transcribe it from history
  • dismiss an already visible/pending recovery capsule immediately when the setting is turned off, without deleting audio that was already saved
  • retain second-Escape dismissal, flash-free double Escape, and paced PCM replay for Qwen realtime ASR
  • merge the latest beta and preserve its Windows selection-voice session guard

Esc routing decision

OpenLess currently observes Esc through a global OS-level event tap before the foreground application handles the key. At that point it can either suppress the event or pass it on, but macOS does not send a later acknowledgement indicating whether a browser/AppKit responder consumed it. Browser bubbling and preventDefault() are internal to the browser process and cannot propagate back to the event tap.

Apple documents the same boundary for event monitors: a global monitor cannot modify/prevent delivery, while a local monitor only controls events dispatched inside its own app. Therefore “let the foreground app consume Esc first, then cancel OpenLess only if it remained unconsumed” is not reliable for a cross-application voice input tool.

The opt-in setting is retained as the deterministic behavior: users who want recoverable Esc cancellation can enable it; everyone else keeps direct cancellation without a recovery capsule.

Behavior

  • default/off: Esc stops and discards the current recording through the existing cancellation path; no recovery UI is shown
  • enabled: Esc stops recording, saves the captured audio locally, writes the pending history entry, and briefly offers Continue
  • Continue: resumes the same session with the previous PCM prepended to the new microphone audio
  • second Esc: dismisses the recovery capsule; a rapid double Esc skips showing it
  • turning the setting off dismisses any pending recovery prompt; recordings already persisted are kept for history integrity

Verification

  • GitHub CI: Android, Linux, Windows, and macOS all passed
  • Rust library tests: 1274 passed, 7 ignored, 0 failed
  • frontend and contract test runner: 60 passed
  • Qwen realtime Rust tests: 26 passed
  • Esc bridge Rust tests: 4 passed
  • recovery preference/gating Rust tests: 3 passed
  • production frontend build passed
  • git diff --check passed

@H-Chris233

Copy link
Copy Markdown
Collaborator

按了就是按了 没按就是没按 没必要做这些东西

@H-Chris233 H-Chris233 closed this Aug 23, 2026
@H-Chris233

Copy link
Copy Markdown
Collaborator

更何况还是默认的 会烦人

@H-Chris233 H-Chris233 reopened this Aug 23, 2026
@H-Chris233

Copy link
Copy Markdown
Collaborator

鉴于是冷门路径 我再考虑一下

@MarkShawn2020

Copy link
Copy Markdown
Contributor Author

更何况还是默认的 会烦人

可以作为一个开关吧

@H-Chris233

Copy link
Copy Markdown
Collaborator

可以 那你加开关

@H-Chris233
H-Chris233 marked this pull request as draft August 26, 2026 07:51
@MarkShawn2020

MarkShawn2020 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

已按讨论完成优化:

  • 新增「保留 Esc 取消的录音」设置,macOS / Windows 可见,默认关闭。
  • 关闭时沿用原来的直接取消路径,不写恢复历史,也不显示 Continue 胶囊。
  • 开启后才保存录音并显示继续入口;若用户在提示存在时关掉设置,提示会立即收起。

关于「仅在前台应用没有消费 Esc 时才由 OpenLess 处理」:当前 CGEventTap 回调发生在目标应用分发按键之前,只能当场决定吞掉或放行;浏览器/AppKit 处理后不会向全局事件 tap 回传 consumed 状态,DOM 的 preventDefault() 也只在浏览器进程内有效。因此跨应用无法可靠实现“先让网页消费、未消费再交给 OpenLess”。

本次已合并最新 beta,冲突已解决;本地 Rust 全量测试 1274 通过、前端/契约 60 通过、生产前端构建通过。PR 当前已从 conflicting 变为 mergeable,Android、Linux、Windows、macOS 四平台 CI 均已通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants